const express =require('express')
const router =express.Router()
module.exports =router

const db = require('../db')
const {formatDate} = require('../utils/utils')

//实现登录接口（POST /api/login）
router.post('/login',async (req,res)=>{
    const { username, password } = req.query;
    const result = await db.reg(username, password)
    if(result){
        res.send(formatData.success(result[0]))
    }else{
        res.send(formatData.fail())
    }
})